<div class="modal-content" style="min-height: 500px">

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"
                aria-label="Close"><span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="detailsModalLabel">
            更改{{ type_name or '产品' }}
        </h4>
    </div>

    <div class="modal-body clearfix">
        <select id="product-option">
            {% for option in options %}
            <option {% if option.product_id == product_id %}
                    selected=selected {% endif %}
                    value={{ option.product_id }}>【产品名称：{{ option.product_name }}】【品牌：{{ option.brand }} 】【价格：{{ option.suggest_price }}元】</option>
            {% endfor %}
        </select>
        <button id="select-product-btn"
                class="btn-group btn btn-primary pull-right">提交
        </button>
    </div>

</div>
<script>
    $.fn.select2.defaults.set("width", "80%");
    $('select').select2();
    $('[data-toggle="tooltip"]').tooltip();
    $(document).ready(function () {
        var type_id = {{ type_id }};
        $("#select-product-btn").click(function () {
            var product_input = $("#product-data");
            var products = product_input.val();
            products = JSON.parse(products);
            var select_value = $("#product-option").val();
            if (select_value) {
                products[type_id] = select_value;
                product_input.val(JSON.stringify(products));
                $("#add-demand-btn").click();
            }
        });
    });
</script>